<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>VectSharp: VectSharp: a light library for C# vector graphics</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="Doxy.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="icon.svg"/></td>
  <td id="projectalign">
   <div id="projectname">VectSharp<span id="projectnumber">&#160;2.6.1</span>
   </div>
   <div id="projectbrief">A light library for C# vector graphics</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.5 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('index.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title"><a class="el" href="namespace_vect_sharp.html">VectSharp</a>: a light library for C# vector graphics </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p ><a class="anchor" id="md_Readme"></a> <img src="icon.svg" alt="" style="pointer-events: none;" width="256" align="right" class="inline"/></p>
<p ><a href="https://www.gnu.org/licenses/lgpl-3.0"><img src="https://img.shields.io/badge/License-LGPL_v3-blue.svg" alt="License: LGPL v3" style="pointer-events: none;" class="inline"/></a> <a href="https://nuget.org/packages/VectSharp"><img src="https://img.shields.io/nuget/v/VectSharp" alt="Version" class="inline"/></a> <a href="https://nuget.org/packages/VectSharp"><img src="https://img.shields.io/nuget/dt/VectSharp" alt="Downloads" class="inline"/></a></p>
<p ><a href="https://arklumpus.github.io/VectSharp"><b>Full documentation with interactive examples</b></a></p>
<h1><a class="anchor" id="autotoc_md1"></a>
Introduction</h1>
<p ><b><a class="el" href="namespace_vect_sharp.html">VectSharp</a></b> is a library to create vector graphics (including text) in C#, without too many dependencies.</p>
<p ><a class="el" href="namespace_vect_sharp.html">VectSharp</a> is written using .NET Core, and is available for Mac, Windows and Linux. Since version 2.0.0, it is released under an LGPLv3 license. It includes 14 standard fonts, originally released under an ASL-2.0 license.</p>
<p >It includes an abstract layer on top of which output layers can be written. Currently, there are five available output layers:</p><ul>
<li><b><a class="el" href="namespace_vect_sharp_1_1_p_d_f.html">VectSharp.PDF</a></b> produces PDF documents.</li>
<li><b><a class="el" href="namespace_vect_sharp_1_1_canvas.html">VectSharp.Canvas</a></b> produces an <code>Avalonia.Controls.Canvas</code> object (<a href="https://avaloniaui.net/docs/controls/canvas">https://avaloniaui.net/docs/controls/canvas</a>) containing the rendered graphics objects.</li>
<li><b><a class="el" href="namespace_vect_sharp_1_1_s_v_g.html">VectSharp.SVG</a></b> produces vector graphics in SVG format.</li>
<li><b><a class="el" href="namespace_vect_sharp_1_1_raster.html">VectSharp.Raster</a></b> produces raster images in PNG format, (this is done by rendering the image to a PDF document, and then using the <a href="https://github.com/arklumpus/MuPDFCore">MuPDFCore</a> library to render the PDF). Since version 2.0.0, <a class="el" href="namespace_vect_sharp_1_1_raster.html">VectSharp.Raster</a> is released under an AGPLv3 licence.</li>
<li><b><a class="el" href="namespace_vect_sharp_1_1_raster_1_1_image_sharp.html">VectSharp.Raster.ImageSharp</a></b> produces raster images in multiple formats (BMP, GIF, JPEG, PBM, PNG, TGA, TIFF, WebP) using the <a href="https://github.com/SixLabors/ImageSharp">SixLabors.ImageSharp</a> library.</li>
</ul>
<p ><a class="el" href="namespace_vect_sharp_1_1_raster.html">VectSharp.Raster</a> and <a class="el" href="namespace_vect_sharp_1_1_raster_1_1_image_sharp.html">VectSharp.Raster.ImageSharp</a> are somewhat overlapping, as both of them can be used to create PNG images. However, <a class="el" href="namespace_vect_sharp_1_1_raster.html">VectSharp.Raster</a> is much faster, though it only supports the PNG format. Instead, <a class="el" href="namespace_vect_sharp_1_1_raster_1_1_image_sharp.html">VectSharp.Raster.ImageSharp</a> is slower, but supports more formats and has a more permissive licence. Another difference is that <a class="el" href="namespace_vect_sharp_1_1_raster.html">VectSharp.Raster</a> carries a native dependency (through MuPDFCore), while VectSharp.ImageSharp does not.</p>
<p >Furthermore:</p><ul>
<li>The <a href="https://arklumpus.github.io/VectSharp/plots.html"><b>VectSharp.Plots</b></a> package contains classes and methods to draw plots (such as scatter plots, line charts, bar charts, box plots, function plots, and more).</li>
<li><a href="https://github.com/arklumpus/VectSharp/tree/master/VectSharp.ThreeD"><b>VectSharp.ThreeD</b></a> adds support for 3D vector and raster graphics.</li>
<li><a href="https://github.com/arklumpus/VectSharp/tree/master/VectSharp.Markdown"><b>VectSharp.Markdown</b></a> can be used to transform Markdown documents into <a class="el" href="namespace_vect_sharp.html">VectSharp</a> objects, that can then be exported e.g. as PDF or SVG files, or displayed in an Avalonia <code>Canvas</code>. <b><a class="el" href="namespace_vect_sharp_1_1_markdown_canvas.html">VectSharp.MarkdownCanvas</a></b> uses <a class="el" href="namespace_vect_sharp_1_1_markdown.html">VectSharp.Markdown</a> to render Markdown documents in Avalonia applications (an example of this is in the <a href="https://github.com/arklumpus/VectSharp/tree/master/MarkdownViewerDemo">MarkdownViewerDemo project</a>).</li>
<li><b><a class="el" href="namespace_vect_sharp_1_1_mu_p_d_f_utils.html">VectSharp.MuPDFUtils</a></b>, released under an AGPLv3 licence, contains some utility functions that use <a href="https://github.com/arklumpus/MuPDFCore">MuPDFCore</a> to make it possible to include in <a class="el" href="namespace_vect_sharp.html">VectSharp</a> graphics images in various formats.</li>
<li><b><a class="el" href="namespace_vect_sharp_1_1_image_sharp_utils.html">VectSharp.ImageSharpUtils</a></b> adds the same capabilities as <a class="el" href="namespace_vect_sharp_1_1_mu_p_d_f_utils.html">VectSharp.MuPDFUtils</a>, using ImageSharp instead of MuPDFCore; as a result, it is released under a more permissive LGPLv3 licence.</li>
<li><b><a class="el" href="class_vect_sharp_1_1_fonts_1_1_nimbus.html" title="Contains an IFontLibrary providing access to the Nimbus family of standard fonts (used e....">VectSharp.Fonts.Nimbus</a></b> is a package released under a GPLv3 license, which contains the standard fonts that were used in <a class="el" href="namespace_vect_sharp.html">VectSharp</a> before version 2.0.0. Since these fonts are released under a GPL license, they had to be replaced when the <a class="el" href="namespace_vect_sharp.html">VectSharp</a> license changed to LGPL. See the [Font libraries](section) below for information on how to re-enable these fonts.</li>
<li>The <b>Animation</b> class (provided in the base <a class="el" href="namespace_vect_sharp.html">VectSharp</a> package) can be used to create animations that can be saved as animated GIFs (using <a class="el" href="namespace_vect_sharp_1_1_raster_1_1_image_sharp.html">VectSharp.Raster.ImageSharp</a>), SVGs (using <a class="el" href="namespace_vect_sharp_1_1_s_v_g.html">VectSharp.SVG</a>) and PNGs (using <a class="el" href="namespace_vect_sharp_1_1_raster.html">VectSharp.Raster</a> or <a class="el" href="namespace_vect_sharp_1_1_raster_1_1_image_sharp.html">VectSharp.Raster.ImageSharp</a>).</li>
</ul>
<p ><img src="https://user-images.githubusercontent.com/32712606/209444145-e4833187-37a7-4682-9f64-a16d1d03d84c.gif" alt="" style="width: 90%" class="inline"/>  </p>
<h1><a class="anchor" id="autotoc_md2"></a>
Installing VectSharp</h1>
<p >To include <a class="el" href="namespace_vect_sharp.html">VectSharp</a> in your project, you will need one of the output layer NuGet packages: <a href="https://www.nuget.org/packages/VectSharp.PDF/">VectSharp.PDF</a>, <a href="https://www.nuget.org/packages/VectSharp.Canvas/">VectSharp.Canvas</a>, <a href="https://www.nuget.org/packages/VectSharp.Raster/">VectSharp.Raster</a>, <a href="https://www.nuget.org/packages/VectSharp.Raster.ImageSharp/">VectSharp.Raster.ImageSharp</a>, or <a href="https://www.nuget.org/packages/VectSharp.SVG/">VectSharp.SVG</a>. You will need <a href="https://www.nuget.org/packages/VectSharp.ThreeD/">VectSharp.ThreeD</a> to work with 3D graphics or <a href="https://www.nuget.org/packages/VectSharp.Plots/">VectSharp.Plots</a> to create plots. You may want the <a href="https://www.nuget.org/packages/VectSharp.MuPDFUtils/">VectSharp.MuPDFUtils</a> package if you wish to manipulate raster images, and the <a href="https://www.nuget.org/packages/VectSharp.Fonts.Nimbus/">VectSharp.Fonts.Nimbus</a> if you want to restore the GPL-licensed fonts used in previous versions of the library.</p>
<h1><a class="anchor" id="autotoc_md3"></a>
Usage</h1>
<p >You can find detailed documentation for the <a class="el" href="namespace_vect_sharp.html">VectSharp</a> library, <b>including interactive examples</b>, at the <a href="https://arklumpus.github.io/VectSharp">documentation website</a>. A comprehensive API reference is also available, both as a <a href="https://arklumpus.github.io/VectSharp/api">website</a> and as a <a href="https://arklumpus.github.io/VectSharp/api/VectSharp.pdf">PDF manual</a>.</p>
<p >In general, working with <a class="el" href="namespace_vect_sharp.html">VectSharp</a> involves: creating a <code>Document</code>, adding <code>Page</code>s, drawing to the <code>Page</code>s' <code>Graphics</code> objects and, finally, exporting them to a PDF document, <code>Canvas</code>, PNG image or SVG document.</p>
<ul>
<li>Create a <code>Document</code>: <div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp.html">VectSharp</a>;</div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_document.html">Document</a> doc = <span class="keyword">new</span> <a class="code hl_class" href="class_vect_sharp_1_1_document.html">Document</a>();</div>
<div class="ttc" id="aclass_vect_sharp_1_1_document_html"><div class="ttname"><a href="class_vect_sharp_1_1_document.html">VectSharp.Document</a></div><div class="ttdoc">Represents a collection of pages.</div><div class="ttdef"><b>Definition:</b> <a href="_document_8cs_source.html#l00027">Document.cs:28</a></div></div>
<div class="ttc" id="anamespace_vect_sharp_html"><div class="ttname"><a href="namespace_vect_sharp.html">VectSharp</a></div><div class="ttdef"><b>Definition:</b> <a href="_animation_8cs_source.html#l00025">Animation.cs:26</a></div></div>
</div><!-- fragment --></li>
<li>Add a <code>Page</code>: <div class="fragment"><div class="line">doc.<a class="code hl_variable" href="class_vect_sharp_1_1_document.html#a37c0a15de4cf1ce2ea3bc6ae074c18c9">Pages</a>.Add(<span class="keyword">new</span> <a class="code hl_class" href="class_vect_sharp_1_1_page.html">Page</a>(1000, 1000));</div>
<div class="ttc" id="aclass_vect_sharp_1_1_document_html_a37c0a15de4cf1ce2ea3bc6ae074c18c9"><div class="ttname"><a href="class_vect_sharp_1_1_document.html#a37c0a15de4cf1ce2ea3bc6ae074c18c9">VectSharp.Document.Pages</a></div><div class="ttdeci">List&lt; Page &gt; Pages</div><div class="ttdoc">The pages in the document.</div><div class="ttdef"><b>Definition:</b> <a href="_document_8cs_source.html#l00032">Document.cs:32</a></div></div>
<div class="ttc" id="aclass_vect_sharp_1_1_page_html"><div class="ttname"><a href="class_vect_sharp_1_1_page.html">VectSharp.Page</a></div><div class="ttdoc">Represents a Graphics object with a width and height.</div><div class="ttdef"><b>Definition:</b> <a href="_document_8cs_source.html#l00047">Document.cs:48</a></div></div>
</div><!-- fragment --></li>
<li>Draw to the <code>Page</code>'s <code>Graphics</code> object: <div class="fragment"><div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_graphics.html">Graphics</a> gpr = doc.<a class="code hl_variable" href="class_vect_sharp_1_1_document.html#a37c0a15de4cf1ce2ea3bc6ae074c18c9">Pages</a>.Last().Graphics;</div>
<div class="line">gpr.<a class="code hl_function" href="class_vect_sharp_1_1_graphics.html#a30201a35455b7ef559703aebf8525f50">FillRectangle</a>(100, 100, 800, 800, <a class="code hl_struct" href="struct_vect_sharp_1_1_colour.html">Colour</a>.<a class="code hl_function" href="struct_vect_sharp_1_1_colour.html#a80787f39829f01b38291bb429214d6ae">FromRgb</a>(128, 128, 128));</div>
<div class="ttc" id="aclass_vect_sharp_1_1_graphics_html"><div class="ttname"><a href="class_vect_sharp_1_1_graphics.html">VectSharp.Graphics</a></div><div class="ttdoc">Represents an abstract drawing surface.</div><div class="ttdef"><b>Definition:</b> <a href="_graphics_8cs_source.html#l00279">Graphics.cs:280</a></div></div>
<div class="ttc" id="aclass_vect_sharp_1_1_graphics_html_a30201a35455b7ef559703aebf8525f50"><div class="ttname"><a href="class_vect_sharp_1_1_graphics.html#a30201a35455b7ef559703aebf8525f50">VectSharp.Graphics.FillRectangle</a></div><div class="ttdeci">void FillRectangle(Point topLeft, Size size, Brush fillColour, string tag=null)</div><div class="ttdoc">Fill a rectangle.</div><div class="ttdef"><b>Definition:</b> <a href="_graphics_8cs_source.html#l00469">Graphics.cs:469</a></div></div>
<div class="ttc" id="astruct_vect_sharp_1_1_colour_html"><div class="ttname"><a href="struct_vect_sharp_1_1_colour.html">VectSharp.Colour</a></div><div class="ttdoc">Represents an RGB colour.</div><div class="ttdef"><b>Definition:</b> <a href="_colour_8cs_source.html#l00028">Colour.cs:29</a></div></div>
<div class="ttc" id="astruct_vect_sharp_1_1_colour_html_a80787f39829f01b38291bb429214d6ae"><div class="ttname"><a href="struct_vect_sharp_1_1_colour.html#a80787f39829f01b38291bb429214d6ae">VectSharp.Colour.FromRgb</a></div><div class="ttdeci">static Colour FromRgb(double r, double g, double b)</div><div class="ttdoc">Create a new colour from RGB (red, green and blue) values.</div><div class="ttdef"><b>Definition:</b> <a href="_colour_8cs_source.html#l00065">Colour.cs:65</a></div></div>
</div><!-- fragment --></li>
<li>Save as PDF document: <div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp_1_1_p_d_f.html">VectSharp.PDF</a>;</div>
<div class="line"><span class="comment">//...</span></div>
<div class="line">doc.SaveAsPDF(<span class="stringliteral">@&quot;Sample.pdf&quot;</span>);</div>
<div class="ttc" id="anamespace_vect_sharp_1_1_p_d_f_html"><div class="ttname"><a href="namespace_vect_sharp_1_1_p_d_f.html">VectSharp.PDF</a></div><div class="ttdef"><b>Definition:</b> <a href="_annotation_styles_8cs_source.html#l00021">AnnotationStyles.cs:22</a></div></div>
</div><!-- fragment --></li>
<li>Export the graphics to a <code>Canvas</code>: <div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp_1_1_canvas.html">VectSharp.Canvas</a>;</div>
<div class="line"><span class="comment">//...</span></div>
<div class="line">Avalonia.Controls.Canvas can = doc.<a class="code hl_variable" href="class_vect_sharp_1_1_document.html#a37c0a15de4cf1ce2ea3bc6ae074c18c9">Pages</a>.Last().PaintToCanvas();</div>
<div class="ttc" id="anamespace_vect_sharp_1_1_canvas_html"><div class="ttname"><a href="namespace_vect_sharp_1_1_canvas.html">VectSharp.Canvas</a></div><div class="ttdef"><b>Definition:</b> <a href="_animated_canvas_8cs_source.html#l00023">AnimatedCanvas.cs:24</a></div></div>
</div><!-- fragment --></li>
<li>Export the graphics to a <code>Canvas</code>, using a multi-layer, multi-threaded, triple-buffered renderer based on SkiaSharp (which provides the best performance if you wish e.g. to place the canvas within a <a href="https://github.com/wieslawsoltes/PanAndZoom"><code>ZoomBorder</code></a>): <div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp_1_1_canvas.html">VectSharp.Canvas</a>;</div>
<div class="line"><span class="comment">//...</span></div>
<div class="line"><span class="comment">// A single page</span></div>
<div class="line">Avalonia.Controls.Canvas can = doc.<a class="code hl_variable" href="class_vect_sharp_1_1_document.html#a37c0a15de4cf1ce2ea3bc6ae074c18c9">Pages</a>.Last().PaintToSKCanvas();</div>
<div class="line"> </div>
<div class="line"><span class="comment">// The whole document - each page will correspond to a layer</span></div>
<div class="line">Avalonia.Controls.Canvas can = doc.PaintToSKCanvas();</div>
</div><!-- fragment --></li>
<li>Save as a PNG image: <div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp_1_1_raster.html">VectSharp.Raster</a>;</div>
<div class="line"><span class="comment">//...</span></div>
<div class="line">doc.<a class="code hl_variable" href="class_vect_sharp_1_1_document.html#a37c0a15de4cf1ce2ea3bc6ae074c18c9">Pages</a>.Last().SaveAsPNG(<span class="stringliteral">@&quot;Sample.png&quot;</span>);</div>
<div class="ttc" id="anamespace_vect_sharp_1_1_raster_html"><div class="ttname"><a href="namespace_vect_sharp_1_1_raster.html">VectSharp.Raster</a></div><div class="ttdef"><b>Definition:</b> <a href="_raster_8cs_source.html#l00025">Raster.cs:26</a></div></div>
</div><!-- fragment --></li>
<li>Save as a JPEG image: <div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp_1_1_raster_1_1_image_sharp.html">VectSharp.Raster.ImageSharp</a>;</div>
<div class="line"><span class="comment">//...</span></div>
<div class="line">doc.<a class="code hl_variable" href="class_vect_sharp_1_1_document.html#a37c0a15de4cf1ce2ea3bc6ae074c18c9">Pages</a>.Last().SaveAsImage(<span class="stringliteral">@&quot;Sample.jpg&quot;</span>);</div>
<div class="ttc" id="anamespace_vect_sharp_1_1_raster_1_1_image_sharp_html"><div class="ttname"><a href="namespace_vect_sharp_1_1_raster_1_1_image_sharp.html">VectSharp.Raster.ImageSharp</a></div><div class="ttdef"><b>Definition:</b> <a href="_gradient_brush_applicator_8cs_source.html#l00027">GradientBrushApplicator.cs:28</a></div></div>
</div><!-- fragment --></li>
<li>Save as an SVG document: <div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp_1_1_s_v_g.html">VectSharp.SVG</a>;</div>
<div class="line"><span class="comment">//...</span></div>
<div class="line">doc.<a class="code hl_variable" href="class_vect_sharp_1_1_document.html#a37c0a15de4cf1ce2ea3bc6ae074c18c9">Pages</a>.Last().SaveAsSVG(<span class="stringliteral">@&quot;Sample.svg&quot;</span>);</div>
<div class="ttc" id="anamespace_vect_sharp_1_1_s_v_g_html"><div class="ttname"><a href="namespace_vect_sharp_1_1_s_v_g.html">VectSharp.SVG</a></div><div class="ttdef"><b>Definition:</b> <a href="_s_v_g_context_8cs_source.html#l00030">SVGContext.cs:31</a></div></div>
</div><!-- fragment --></li>
<li>PDF and SVG documents support both internal and external links: <div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp.html">VectSharp</a>;</div>
<div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp_1_1_p_d_f.html">VectSharp.PDF</a>;</div>
<div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp_1_1_s_v_g.html">VectSharp.SVG</a>;</div>
<div class="line"><span class="comment">//...</span></div>
<div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_document.html">Document</a> document = <span class="keyword">new</span> <a class="code hl_class" href="class_vect_sharp_1_1_document.html">Document</a>();</div>
<div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_page.html">Page</a> page = <span class="keyword">new</span> <a class="code hl_class" href="class_vect_sharp_1_1_page.html">Page</a>(1000, 1000);</div>
<div class="line">document.<a class="code hl_variable" href="class_vect_sharp_1_1_document.html#a37c0a15de4cf1ce2ea3bc6ae074c18c9">Pages</a>.Add(page);</div>
<div class="line"> </div>
<div class="line">page.<a class="code hl_property" href="class_vect_sharp_1_1_page.html#a6a3757a9f2e8efc2dceca8d99fff9ace">Graphics</a>.<a class="code hl_function" href="class_vect_sharp_1_1_graphics.html#a30201a35455b7ef559703aebf8525f50">FillRectangle</a>(100, 100, 800, 50, <a class="code hl_struct" href="struct_vect_sharp_1_1_colour.html">Colour</a>.<a class="code hl_function" href="struct_vect_sharp_1_1_colour.html#a80787f39829f01b38291bb429214d6ae">FromRgb</a>(128, 128, 128), tag: <span class="stringliteral">&quot;linkToGitHub&quot;</span>);</div>
<div class="line">page.<a class="code hl_property" href="class_vect_sharp_1_1_page.html#a6a3757a9f2e8efc2dceca8d99fff9ace">Graphics</a>.<a class="code hl_function" href="class_vect_sharp_1_1_graphics.html#a30201a35455b7ef559703aebf8525f50">FillRectangle</a>(100, 300, 800, 50, <a class="code hl_struct" href="struct_vect_sharp_1_1_colour.html">Colour</a>.<a class="code hl_function" href="struct_vect_sharp_1_1_colour.html#a80787f39829f01b38291bb429214d6ae">FromRgb</a>(255, 0, 0), tag: <span class="stringliteral">&quot;linkToBlueRectangle&quot;</span>);</div>
<div class="line">page.<a class="code hl_property" href="class_vect_sharp_1_1_page.html#a6a3757a9f2e8efc2dceca8d99fff9ace">Graphics</a>.<a class="code hl_function" href="class_vect_sharp_1_1_graphics.html#a30201a35455b7ef559703aebf8525f50">FillRectangle</a>(100, 850, 800, 50, <a class="code hl_struct" href="struct_vect_sharp_1_1_colour.html">Colour</a>.<a class="code hl_function" href="struct_vect_sharp_1_1_colour.html#a80787f39829f01b38291bb429214d6ae">FromRgb</a>(0, 0, 255), tag: <span class="stringliteral">&quot;blueRectangle&quot;</span>);</div>
<div class="line"> </div>
<div class="line">Dictionary&lt;string, string&gt; links = <span class="keyword">new</span> Dictionary&lt;string, string&gt;() { { <span class="stringliteral">&quot;linkToGitHub&quot;</span>, <span class="stringliteral">&quot;https://github.com/&quot;</span> }, { <span class="stringliteral">&quot;linkToBlueRectangle&quot;</span>, <span class="stringliteral">&quot;#blueRectangle&quot;</span> } };</div>
<div class="line"> </div>
<div class="line">page.SaveAsSVG(<span class="stringliteral">@&quot;Links.svg&quot;</span>, linkDestinations: links);</div>
<div class="line">document.SaveAsPDF(<span class="stringliteral">@&quot;Links.pdf&quot;</span>, linkDestinations: links);</div>
<div class="ttc" id="aclass_vect_sharp_1_1_page_html_a6a3757a9f2e8efc2dceca8d99fff9ace"><div class="ttname"><a href="class_vect_sharp_1_1_page.html#a6a3757a9f2e8efc2dceca8d99fff9ace">VectSharp.Page.Graphics</a></div><div class="ttdeci">Graphics Graphics</div><div class="ttdoc">Graphics surface of the page.</div><div class="ttdef"><b>Definition:</b> <a href="_document_8cs_source.html#l00062">Document.cs:62</a></div></div>
</div><!-- fragment --> This code produces a document with three rectangles: the grey one at the top links to the GitHub home page, while the red one in the middle is a hyperlink to the blue one at the bottom. Links in PDF documents can refer to objects that are in a different page than the one containing the link.</li>
</ul>
<p >The public classes and methods are <a href="https://arklumpus.github.io/VectSharp">fully documented</a> (with interactive examples created using Blazor), and you can find a (much) more detailed code example in <a href="https://github.com/arklumpus/VectSharp/blob/master/VectSharp.Demo/MainWindow.xaml.cs">MainWindow.xaml.cs</a>. A detailed guide about 3D graphics in <a class="el" href="namespace_vect_sharp_1_1_three_d.html">VectSharp.ThreeD</a> is available in the <a href="https://github.com/arklumpus/VectSharp/tree/master/VectSharp.ThreeD"><code>VectSharp.ThreeD</code></a> folder. Further example code for animations is available in the <a href="https://github.com/arklumpus/VectSharp/blob/master/VectSharp.DemoAnimation/MainWindow.axaml.cs">DemoAnimation project</a>.</p>
<h1><a class="anchor" id="autotoc_md4"></a>
Font libraries</h1>
<p >Since version 2.0.0, font names are resolved using a "font library". This is a class that implements the <code><a class="el" href="interface_vect_sharp_1_1_i_font_library.html" title="Represents a font library with methods to create FontFamily objects from a string or from FontFamily....">VectSharp.IFontLibrary</a></code> interface, providing methods to obtain a <code>FontFamily</code> object from a <code>string</code> or a <code>FontFamily.StandardFontFamilies</code> enumeration. The default font library included in <a class="el" href="namespace_vect_sharp.html">VectSharp</a> uses the embedded fonts (Arimo, Tinos, Cousine) as the standard font families.</p>
<p >In practice, assuming you want to use the default font library, you have the following options to create a <code>FontFamily</code> object:</p>
<div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp.html">VectSharp</a>;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line"> </div>
<div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a> helvetica = <a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a>.<a class="code hl_function" href="class_vect_sharp_1_1_font_family.html#a54acfc650c637428ea2c9f57be1679c2">ResolveFontFamily</a>(<a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a>.<a class="code hl_enumeration" href="class_vect_sharp_1_1_font_family.html#a6cdec4eb0a660064bc416e81f69d3780">StandardFontFamilies</a>.Helvetica); <span class="comment">// Will resolve to the Arimo font family.</span></div>
<div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a> times = <a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a>.<a class="code hl_function" href="class_vect_sharp_1_1_font_family.html#a54acfc650c637428ea2c9f57be1679c2">ResolveFontFamily</a>(<span class="stringliteral">&quot;Times-Roman&quot;</span>); <span class="comment">// Will resolve to the Tinos font family.</span></div>
<div class="ttc" id="aclass_vect_sharp_1_1_font_family_html"><div class="ttname"><a href="class_vect_sharp_1_1_font_family.html">VectSharp.FontFamily</a></div><div class="ttdoc">Represents a typeface.</div><div class="ttdef"><b>Definition:</b> <a href="_font_8cs_source.html#l00423">Font.cs:424</a></div></div>
<div class="ttc" id="aclass_vect_sharp_1_1_font_family_html_a54acfc650c637428ea2c9f57be1679c2"><div class="ttname"><a href="class_vect_sharp_1_1_font_family.html#a54acfc650c637428ea2c9f57be1679c2">VectSharp.FontFamily.ResolveFontFamily</a></div><div class="ttdeci">static FontFamily ResolveFontFamily(string fontFamily)</div><div class="ttdoc">Create a new font family from the specified family name or true type file. If the family name or the ...</div></div>
<div class="ttc" id="aclass_vect_sharp_1_1_font_family_html_a6cdec4eb0a660064bc416e81f69d3780"><div class="ttname"><a href="class_vect_sharp_1_1_font_family.html#a6cdec4eb0a660064bc416e81f69d3780">VectSharp.FontFamily.StandardFontFamilies</a></div><div class="ttdeci">StandardFontFamilies</div><div class="ttdoc">The 14 standard font families.</div><div class="ttdef"><b>Definition:</b> <a href="_font_8cs_source.html#l00502">Font.cs:503</a></div></div>
</div><!-- fragment --><p >These replace the <code>FontFamily(string)</code> and <code>FontFamily(StandardFontFamilies)</code> constructors of previous versions of <a class="el" href="namespace_vect_sharp.html">VectSharp</a>. Overloads of this method let you specify a list of "fallback" fonts that will be used if the first font you specify is not available.</p>
<p >If you wish, you can replace the default font library with a different one; this will change the way font families are resolved. For example, after installing the <a href="https://www.nuget.org/packages/VectSharp.Fonts.Nimbus/">VectSharp.Fonts.Nimbus</a> NuGet package, you can do:</p>
<div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp.html">VectSharp</a>;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line"> </div>
<div class="line">FontFamily.DefaultFontLibrary = <a class="code hl_namespace" href="namespace_vect_sharp.html">VectSharp</a>.<a class="code hl_namespace" href="namespace_vect_sharp_1_1_fonts.html">Fonts</a>.<a class="code hl_class" href="class_vect_sharp_1_1_fonts_1_1_nimbus.html">Nimbus</a>.<a class="code hl_property" href="class_vect_sharp_1_1_fonts_1_1_nimbus.html#af518e6038274bd7a9b766e038563ae0f">Library</a>;</div>
<div class="line"> </div>
<div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a> helvetica = <a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a>.<a class="code hl_function" href="class_vect_sharp_1_1_font_family.html#a54acfc650c637428ea2c9f57be1679c2">ResolveFontFamily</a>(<a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a>.<a class="code hl_enumeration" href="class_vect_sharp_1_1_font_family.html#a6cdec4eb0a660064bc416e81f69d3780">StandardFontFamilies</a>.Helvetica); <span class="comment">// Will resolve to the Nimbus Sans L font family.</span></div>
<div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a> times = <a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a>.<a class="code hl_function" href="class_vect_sharp_1_1_font_family.html#a54acfc650c637428ea2c9f57be1679c2">ResolveFontFamily</a>(<span class="stringliteral">&quot;Times-Roman&quot;</span>); <span class="comment">// Will resolve to the Nimbus Roman No 9 L font family.</span></div>
<div class="ttc" id="aclass_vect_sharp_1_1_fonts_1_1_nimbus_html"><div class="ttname"><a href="class_vect_sharp_1_1_fonts_1_1_nimbus.html">VectSharp.Fonts.Nimbus</a></div><div class="ttdoc">Contains an IFontLibrary providing access to the Nimbus family of standard fonts (used e....</div><div class="ttdef"><b>Definition:</b> <a href="_nimbus_8cs_source.html#l00021">Nimbus.cs:22</a></div></div>
<div class="ttc" id="aclass_vect_sharp_1_1_fonts_1_1_nimbus_html_af518e6038274bd7a9b766e038563ae0f"><div class="ttname"><a href="class_vect_sharp_1_1_fonts_1_1_nimbus.html#af518e6038274bd7a9b766e038563ae0f">VectSharp.Fonts.Nimbus.Library</a></div><div class="ttdeci">static IFontLibrary Library</div><div class="ttdoc">The font library.</div><div class="ttdef"><b>Definition:</b> <a href="_nimbus_8cs_source.html#l00026">Nimbus.cs:26</a></div></div>
<div class="ttc" id="anamespace_vect_sharp_1_1_fonts_html"><div class="ttname"><a href="namespace_vect_sharp_1_1_fonts.html">VectSharp.Fonts</a></div><div class="ttdef"><b>Definition:</b> <a href="_nimbus_8cs_source.html#l00016">Nimbus.cs:17</a></div></div>
</div><!-- fragment --><p >This will let you re-enable the fonts that were used in previous versions of <a class="el" href="namespace_vect_sharp.html">VectSharp</a>.</p>
<p >You can also use multiple font libraries in the same project. Again, assuming you have installed the <a class="el" href="class_vect_sharp_1_1_fonts_1_1_nimbus.html" title="Contains an IFontLibrary providing access to the Nimbus family of standard fonts (used e....">VectSharp.Fonts.Nimbus</a> NuGet package:</p>
<div class="fragment"><div class="line"><span class="keyword">using </span><a class="code hl_namespace" href="namespace_vect_sharp.html">VectSharp</a>;</div>
<div class="line"> </div>
<div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a> helvetica1 = <a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a>.<a class="code hl_function" href="class_vect_sharp_1_1_font_family.html#a54acfc650c637428ea2c9f57be1679c2">ResolveFontFamily</a>(<a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a>.<a class="code hl_enumeration" href="class_vect_sharp_1_1_font_family.html#a6cdec4eb0a660064bc416e81f69d3780">StandardFontFamilies</a>.Helvetica); <span class="comment">// Will resolve to the Arimo font family.</span></div>
<div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a> times1 = <a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a>.<a class="code hl_function" href="class_vect_sharp_1_1_font_family.html#a54acfc650c637428ea2c9f57be1679c2">ResolveFontFamily</a>(<span class="stringliteral">&quot;Times-Roman&quot;</span>); <span class="comment">// Will resolve to the Tinos font family.</span></div>
<div class="line"> </div>
<div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a> helvetica2 = <a class="code hl_namespace" href="namespace_vect_sharp.html">VectSharp</a>.<a class="code hl_namespace" href="namespace_vect_sharp_1_1_fonts.html">Fonts</a>.<a class="code hl_class" href="class_vect_sharp_1_1_fonts_1_1_nimbus.html">Nimbus</a>.ResolveFontFamily(<a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a>.<a class="code hl_enumeration" href="class_vect_sharp_1_1_font_family.html#a6cdec4eb0a660064bc416e81f69d3780">StandardFontFamilies</a>.Helvetica); <span class="comment">// Will resolve to the Nimbus Sans L font family.</span></div>
<div class="line"><a class="code hl_class" href="class_vect_sharp_1_1_font_family.html">FontFamily</a> times2 = <a class="code hl_namespace" href="namespace_vect_sharp.html">VectSharp</a>.<a class="code hl_namespace" href="namespace_vect_sharp_1_1_fonts.html">Fonts</a>.<a class="code hl_class" href="class_vect_sharp_1_1_fonts_1_1_nimbus.html">Nimbus</a>.ResolveFontFamily(<span class="stringliteral">&quot;Times-Roman&quot;</span>); <span class="comment">// Will resolve to the Nimbus Roman No 9 L font family.</span></div>
</div><!-- fragment --><p >Finally, you can create your own font library class (which could implement things such as dowloading fonts from Google Fonts, or finding them in the user's system font directory...) by creating a class that implements the <code>IFontLibrary</code> interface or that extends the <code>FontLibrary</code> class (in this latter case, you get a default implementation for the <code>ResolveFontFamily</code> overloads that use a list of fallback fonts).</p>
<h1><a class="anchor" id="autotoc_md5"></a>
Creating new output layers</h1>
<p ><a class="el" href="namespace_vect_sharp.html">VectSharp</a> can be easily extended to provide additional output layers. To do so:</p><ol type="1">
<li>Create a new class implementing the <code>IGraphicsContext</code> interface.</li>
<li>Provide an extension method to either the <code>Page</code> or <code>Document</code> types.</li>
<li>Somewhere in the extension method, call the <code>CopyToIGraphicsContext</code> method on the <code>Graphics</code> object of the <code>Page</code>s.</li>
<li>Opportunely save or return the rendered result.</li>
</ol>
<h1><a class="anchor" id="autotoc_md6"></a>
Compiling VectSharp from source</h1>
<p >The <a class="el" href="namespace_vect_sharp.html">VectSharp</a> source code includes an example project (<em>VectSharp.Demo</em>) presenting how <a class="el" href="namespace_vect_sharp.html">VectSharp</a> can be used to produce graphics.</p>
<p >To be able to compile <a class="el" href="namespace_vect_sharp.html">VectSharp</a> from source, you will need to install the latest <a href="https://dotnet.microsoft.com/download/dotnet/current">.NET SDK</a> for your operating system.</p>
<p >You can use <a href="https://visualstudio.microsoft.com/it/vs/">Microsoft Visual Studio</a> to compile the program. The following instructions will cover compiling <a class="el" href="namespace_vect_sharp.html">VectSharp</a> from the command line, instead.</p>
<p >First of all, you will need to download the <a class="el" href="namespace_vect_sharp.html">VectSharp</a> source code: <a href="https://github.com/arklumpus/VectSharp/archive/v2.2.1.tar.gz">VectSharp.tar.gz</a> and extract it somewhere.</p>
<h2><a class="anchor" id="autotoc_md7"></a>
Windows</h2>
<p >Open a command-line window in the folder where you have extracted the source code, and type: </p><pre class="fragment">BuildDemo &lt;Target&gt;
</pre><p> Where <code>&lt;Target&gt;</code> can be one of <code>Win-x64</code>, <code>Linux-x64</code> or <code>Mac-x64</code> depending on which platform you wish to generate executables for.</p>
<p >In the Release folder and in the appropriate subfolder for the target platform you selected, you will find the compiled program.</p>
<h2><a class="anchor" id="autotoc_md8"></a>
macOS and Linux</h2>
<p >Open a terminal in the folder where you have extracted the source code, and type: </p><pre class="fragment">./BuildDemo.sh &lt;Target&gt;
</pre><p> Where <code>&lt;Target&gt;</code> can be one of <code>Win-x64</code>, <code>Linux-x64</code> or <code>Mac-x64</code> depending on which platform you wish to generate executables for.</p>
<p >In the Release folder and in the appropriate subfolder for the target platform you selected, you will find the compiled program.</p>
<p >If you receive an error about permissions being denied, try typing <code>chmod +x BuildDemo.sh</code> first.</p>
<h1><a class="anchor" id="autotoc_md9"></a>
Note about VectSharp.MuPDFUtils and .NET Framework</h1>
<p >If you wish to use <a class="el" href="namespace_vect_sharp_1_1_mu_p_d_f_utils.html">VectSharp.MuPDFUtils</a> in a .NET Framework project, you will need to manually copy the native MuPDFWrapper library for the platform you are using to the executable directory (this is done automatically if you target .NET core).</p>
<p >One way to obtain the appropriate library files is:</p>
<ol type="1">
<li>Manually download the NuGet package for <a href="https://www.nuget.org/packages/MuPDFCore/">MuPFDCore</a> (click on the "Download package" link on the right).</li>
<li>Rename the <code>.nupkg</code> file so that it has a <code>.zip</code> extension.</li>
<li>Extract the zip file.</li>
<li>Within the extracted folder, the library files are in the <code>runtimes/xxx-yyy/native/</code> folder, where <code>xxx</code> is either <code>linux</code>, <code>osx</code> or <code>win</code>, depending on the platform you are using, and <code>yyy</code> is <code>x64</code>, <code>x86</code> or <code>arm64</code> depending on the architecture.</li>
</ol>
<p >Make sure you copy the appropriate file to the same folder as the executable! </p>
</div></div><!-- PageDoc -->
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5 </li>
  </ul>
</div>
</body>
</html>
